#include <iostream>
#include <stack>
#include <string>
#include <cstdio>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ll A, B, D, sum;
stack<ll> OutPut;
int main()
{
    cin >> A >> B >> D;
    sum = A + B;
    do
    {
        OutPut.push(sum % D);
        sum = sum / D;
    } while (sum != 0);

    while (!OutPut.empty())
    {
        printf ("%lld", OutPut.top());
        OutPut.pop();
    }
    return 0;
}